<?php $errmsg = GetMessageStack(); if( $errmsg->size('add_review') > 0 ) $errmsg->output('add_review');?>

<div style="background:#FFF0E1 none repeat scroll 0 0;margin:50px 3px 3px;padding:6px 5px;position:relative;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
• 点评和打分都将是其他网友的参考依据，并影响该网店的评价。<br>
• 用户一天只能对同一家店铺发表一条评论。<br>
• 用户每发表的一个点评都可以得到5-10点贡献值和相同数量的E币。<a target="_blank" class="gray_hint" href="http://www.huakaili.com/help/?subpage=302">什么是贡献值和E币?</a><br>
• 点评如包含商品将获得5分贡献值奖励，包含图片将获得3分贡献值奖励</span><br>
</p>
</div>
<form action="<?php
if( isset($product_page) )
	$urlpostfix = "&product_page=1&pid=$pid";
else 
	$urlpostfix = "";

	  echo edp_href_link('add_review', "sid=$sid" . $urlpostfix) ?>"
	  method="post" enctype="multipart/form-data" onsubmit="return check_validation();" id="add_review_form" grayOnCommit="#userComment" target="hidden_frame">
	
	<iframe name='hidden_frame' id="hidden_frame" style='display:none'></iframe>

	<div class="userComment" id="userComment">
		<div class="usercomment01"></div>
		<div class="usercomment02">
		<a name= "ar" id="ar"></a>
			<h3 id="ar1" class="comment_title">
<?php
			if(isset($pageVars['review']))
			{
				echo '编辑你的评论';
			}
			else
			{
				echo '发表你的评论';
			}
			
?>
			</h3>
			<table border="0" cellspacing="0" cellpadding="0"  class="usercommentTable">
				<tr>
					<td class="usercomment_title">总体评分：</td>
					<td>
						<input type="hidden" name="score" id="score" value="<?php if(isset($pageVars['review'])) echoPageVar($pageVars['review'], "score") ; else echo '-1'; ?>" />
						<div class="scoreback" id="scoreblock" cate="score" baseline="0" distance="38">
							<div class="starplace" href="#" value="0"></div>
							<div class="starplace" href="#" value="1"></div>
							<div class="starplace" href="#" value="2"></div>
							<div class="starplace" href="#" value="3"></div>
							<div class="starplace" href="#" value="4"></div>
						</div>
						<div id="ratingResult"></div>
					</td>
				</tr>
				<tr>
					<td class="usercomment_title">服务态度：</td>
					<td>
						<input type="hidden" name="service" id="service" value="<?php if(isset($pageVars['review'])) echoPageVar($pageVars['review'], "service"); else echo '-1';?>" />

						<div class="starback" id="serviceblock" cate="service" baseline="-334" distance="17">
							<div class="starplace" href="#" value="0"></div>
							<div class="starplace" href="#" value="1"></div>
							<div class="starplace" href="#" value="2"></div>
							<div class="starplace" href="#" value="3"></div>
							<div class="starplace" href="#" value="4"></div>
						</div>
						<div id="ratingResult"></div>
					</td>
				</tr>

				<tr>
					<td class="usercomment_title">宝贝真实度：</td>
					<td>
						<input type="hidden" name="reality" id="reality" value="<?php if(isset($pageVars['review'])) echoPageVar($pageVars['review'], "reality"); else echo '-1'; ?>" />
						<div class="starback" id="realityblock" cate="reality" baseline="-334" distance="17">
							<div class="starplace" href="#" value="0"></div>
							<div class="starplace" href="#" value="1"></div>
							<div class="starplace" href="#" value="2"></div>
							<div class="starplace" href="#" value="3"></div>
							<div class="starplace" href="#" value="4"></div>
						</div>
						<div id="ratingResult"></div>						
					</td>
				</tr>
				<tr>
					<td class="usercomment_title">发货速度：</td>
					<td>
						<input type="hidden" name="velocity" id="velocity" value="<?php if(isset($pageVars['review'])) echoPageVar($pageVars['review'], "velocity"); else echo '-1';?>" />
						<div class="starback" id="velocityblock" cate="velocity" baseline="-334" distance="17">
							<div class="starplace" href="#" value="0"></div>
							<div class="starplace" href="#" value="1"></div>
							<div class="starplace" href="#" value="2"></div>
							<div class="starplace" href="#" value="3"></div>
							<div class="starplace" href="#" value="4"></div>
						</div>
						<div id="ratingResult"></div>						
					</td>
				</tr>
				<tr>
					<td class="usercomment_title">性价比：</td>
					<td><input type="hidden" name="rate" id="rate" value="<?php if(isset($pageVars['review'])) echoPageVar($pageVars['review'], "rate"); else echo '-1';?>" />
						<div class="starback" id="rateblock" cate="rate" baseline="-334" distance="17">
							<div class="starplace" href="#" value="0"></div>
							<div class="starplace" href="#" value="1"></div>
							<div class="starplace" href="#" value="2"></div>
							<div class="starplace" href="#" value="3"></div>
							<div class="starplace" href="#" value="4"></div>
						</div>
						<div id="ratingResult"></div>						
					</td>
				</tr>

				<tr>
					<td class="usercomment_title">点评：</td>
					<td>
						<textarea name="content" id="content" class="textarea_comment" disabled="disabled" ><?php 
							if( isset($content) ) 	secho( preg_replace( "/rn/", "\r", $content) );
							else if( isset($pageVars['review']) ) echoPageVar($pageVars['review'], "content"); 
							else if( edp_isset_session("review_content") ) {secho( preg_replace( "/rn/", "\r", edp_getsession("review_content")) );
								edp_unset_session("review_content");}
							else
								echo "点评内容不得少于50字，不符合规定的点评会被扣分，精彩点评可以获得额外E币奖励。";
						?></textarea>
					</td>
				</tr>
			
				<?php if( isset($pageVars['pics']) && $pageVars['pics']) {?>
				<tr>
					<td class="usercomment_title">已有图片：</td>
					<td>
						<?php foreach( $pageVars['pics'] as $key => $value ) {?>
						<div>
							<a><?php echo $value['name']?></a>
							<input type="hidden" name="ori_pics[]" value="<?php echo $value['id']?>"/>
							<a onclick="del_pic(this)" >删除</a>
						</div>
						<?php }?>
						
					</td>
				</tr>
				<?php }?>
				<tr>
					<td class="usercomment_title">上传图片：</td>
					<td>
						<div style="display: none;" id="uploadlocator"></div>

						<div id="fileblock" class="fileblock">
							<input class="input_1" type="hidden" readonly="readonly" id="picpath" />
							<input class="file_1" type="file" name="files[]" id="files"  onchange="set_file_name(this);"  contenteditable="false" size="30"/>
							<span style="margin-left: 5px;">保存名字：</span> 
							<input type="text" name="picnames[]" id="picnames"  class="pic_name"/> <a onclick="del_file(this);">删除</a>
						</div>

					</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input type="button" onclick="javascript:add_new()" id="button2" value="点击添加图片" class="btn_6" /></td>
				</tr>


				<?php
					global $product_page, $pid;

					if( !isset($product_page) ) {
				?>
				<input type="hidden" name="product_lists" id="product_lists" value="<?php 
				
				if( isset($pageVars['review']) ) 
					if( $pageVars['review']['product_id_list'] != "" )
						echo $pageVars['review']['product_id_list'] . ','; ?>"/>
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>

				<tr>
					<td class="usercomment_title">所买商品：</td>
					<td>
						<div id="product_list">
						
							<?php if( isset($pageVars['products'] )  && is_array($pageVars['products']) && count($pageVars['products']) > 0 ){
								foreach( $pageVars['products'] as $key => $value ) {?>
								<div>
									<a href="#"><?php echo $value["product_name"]?></a>
									<a onclick="remove_from_productlist(<?php echo $value['id']?>,this )" >删除</a>
								</div>
							<?php }}?>
						</div>
						
					<input type="button" onclick="javascript:add_product()" id="button" value="点击添加商品" class="btn_6" /><a id="apTip" href="#" >什么意思？</a></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>
				<?php
				}
				else {
					?>
				<input type="hidden" name="product_page" value="1" />
				<input type="hidden" name="pid" value="<?php secho( $pid ); ?>" />
				<?php
				}
				?>


				<tr>
					<td class="usercomment_title">标签：</td>
					<td><input name="tag" id="tag" type="text" class="tag_input" value="<?php
					if( isset($pageVars['review']) ){
						$tagArray = explode( " " , $pageVars['review']['tag'] );
						foreach( $tagArray as $tagValue ) 
							echo $tagValue . ' ';
					} ?>" /> <span class="gray_hint">空格分开多个标签</span></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>
						<ul class="tags">
							<li class="strong">常用标签：</li>
							<?php
				if(isset($tags)){			      
					$tagArray = explode( " " , $tags );
					foreach( $tagArray as $tagValue ) {
					?>
									<li><a onclick="set_tag(this)"><?php secho( $tagValue );?></a></li>
								<?php
					}
				}
				?>

						</ul>
					</td>
				</tr>
				<tr>
					<td class="usercomment_title">付款方式：</td>
					<td>
						<table border="0" cellpadding="0" cellspacing="0" class="filter_table1">
							<?php 
								$i = 0;
								foreach( $shop_paymethod as $key => $value ){
									if( $i % 5 == 0 )
										echo "<tr>";	
							?>
								<td>
									<input type="checkbox" tag="paymethod" class="input_checkbox" id="paymethod<?php echo ($i+1) ?>" name="paymethod[]" value="<?php echo $value['id']?>" /> <?php echo $value['method_name']?>
								</td>
							<?php 
									if( $i % 5 == 4 )
										echo "</tr>";
									$i++;
								}								
														
								if( ($i-1) % 5 != 4 )
									echo "</tr>";
							?>
						</table>
					</td>
				</tr>
				<tr>
					<td class="usercomment_title">特色：</td>
					<td>
						<table border="0" cellpadding="0" cellspacing="0" class="filter_table1">
							<?php 
								$i = 0;
								foreach( $shop_feature as $key => $value ){
									if( $i % 5 == 0 )
										echo "<tr>";	
							?>
								<td>
									<input type="checkbox" tag="feature" class="input_checkbox" id="feature<?php echo ($i+1)?>" name="feature[]" value="<?php echo $value['id']?>" /> <?php echo $value['feature_name']?>
								</td>
							<?php 
									if( $i % 5 == 4 )
										echo "</tr>";
									$i++;
								}								
														
								if( ($i-1) % 5 != 4 )
									echo "</tr>";
							?>
							
						</table>
					</td>
				</tr>
                                  <tr>  <td class="usercomment_title">  验证码：</td>
                                    <td><input type="text" id="vcode" name="vcode" class="form_text"/>
                                        <span class="form_item" id="vbox">
                                            <img id='vimg'  src="" />&nbsp;&nbsp;<a href="javascript:refresh_vcode(edp_domain_url + 'vcode/?tiny='+Math.random());">换一张</a>
                                        </span>
                                    </td>
                                </tr>
				<tr>
					<td colspan="2" align="center">
						<input type="hidden" id="action" name="action" value="<?php echoPageVar($pageVars, "action")?>" />
						<?php if( isset($pageVars['review']) ) { ?>
						<input type="hidden" name="user_id" value="<?php echoPageVar($pageVars['review'], "user_id")?>" />
						<input type="hidden" name="review_id" value="<?php echoPageVar($pageVars['review'], "id")?>" />
						<input type="hidden" id="paymethod_list" value="<?php echoPageVar( $pageVars['review'], 'paymethod' ); ?>" />
						<input type="hidden" id="feature_list" value="<?php echoPageVar( $pageVars['review'], 'feature' ); ?>" />
						<?php }?>
						<?php if( isset($rid) ) {?>
						<input type="hidden" name="reviewid"  value="<?php echo $rid?>"/>
						<?php }?>
                              
						<input type="submit" class="btn_submit_review" value="" id="submitReview" style="visibility: hidden"/>
					</td>
				</tr>
			</table>
		</div>
		<div class="usercomment03"></div>
	</div>
</form>

<div style="visibility: hidden;" id="ratingPopTip" class="ratingPopTip">
</div>

<div style="visibility: hidden;" id="addProductTip" class="addProductTip">
</div>

<div style="display:none;cursor:default;" class="popup" id="addproduct">
	<form method="post" name="search_product_form" id="search_product_form">
	<input type="hidden" value="<?php echo( $sid );?>" name="sid" />
	<div class="popup1">
		<div class="popup_title">添加我所购买的商品</div>
		<div id="closeWindow" class="popup_close"><a><span>关闭窗口</span></a></div>
	</div>
		<div class="popup2">
			<table border="0" cellspacing="0" cellpadding="0" class="popup_table">
				<tr>
					<td>商品关键字：</td>
					<td><input type="text" name="s_keyword" id="s_keyword" /><input type="submit" class="btn_1" value="搜索" />&nbsp;</td>
					
				</tr>
				<tr>
					<td colspan="2"><div id="result">添加您在点评店铺所购买的商品，以增加点评的可信度，并获得贡献值奖励和更多的推荐机会。</div></td>
				</tr>
			</table>
			<div class="popup_btns">
				
				<input type="button" id="close" class="btn_1" value="确定" />
			</div>
		</div>
		<div class="popup3"></div>
	</form>
</div>
